# Maintainer: kpcyrd <git@rxv.cc>
# Contributor: kpcyrd <git@rxv.cc>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@alpinelinux.org>
pkgname=cjdns
pkgver=21.1
pkgrel=2
pkgdesc="A routing engine designed for security, scalability, speed and ease of use"
url="https://github.com/cjdelisle/cjdns"
#arch="all !mips64 !s390x !ppc64le !riscv64"
license="GPL-3.0-or-later"
makedepends="nodejs python3 linux-headers libseccomp-dev"
install="$pkgname.post-install"
subpackages="$pkgname-doc $pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://github.com/cjdelisle/cjdns/archive/cjdns-v$pkgver.tar.gz
	no-march-flag.patch"

builddir="$srcdir/$pkgname-$pkgname-v$pkgver"

build() {
	export CJDNS_RELEASE_VERSION="$pkgver"
	node ./node_build/make.js
}

check() {
	./cjdroute --help >/dev/null
}

package() {
	install -Dm755 cjdroute "$pkgdir/usr/sbin/cjdroute"
	install -Dm755 contrib/openrc/cjdns "$pkgdir/etc/init.d/cjdns"
	install -Dm644 doc/man/cjdroute.1 \
		"$pkgdir/usr/share/man/man1/cjdroute.1"
	install -Dm644 doc/man/cjdroute.conf.5 \
		"$pkgdir/usr/share/man/man5/cjdroute.conf.5"
	install -Dm 644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md"
	install -Dm644 -t "$pkgdir/usr/share/doc/$pkgname" \
		doc/admin-api.md \
		doc/configure.md \
		doc/djc_layer_model.md \
		doc/nat-gateway.md \
		doc/network-services.md \
		doc/non-root-user.md \
		doc/security_specification.md \
		doc/shorewall_and_vpn_gateway_howto.md \
		doc/tunnel.md
}

sha512sums="5a50b22ce018a8e799ebaa11c0c2998d8a75489c2e54da11b4d9f07f2b00073af34328c431b90afbe6e8796302f2137aa62625dcdd56c0cced785fc2b280ccf6  cjdns-21.1.tar.gz
571c675a83c5464d31ca1dc130d559dea1866013f7e4445fb16a5f9c9d9f9b63c07a9a9714f47abbb3a62ff334b4eeaadd849cb90818bec88be773d525ff7d5f  no-march-flag.patch"
